package com._复习;

public class Test05 {
    public static void main(String[] args) {
        int[] arr = {19, 28, 37, 46, 50};
        System.out.print("反转前");
        prinArray(arr);
        //反转
        reverse(arr);

        System.out.print("反转后");
        prinArray(arr);
    }

    public static void reverse(int[] arr) {
        int a = 0;
        int b = arr.length - 1;
        while (a < b) {
            int temp = arr[a];
            arr[a] = arr[b];
            arr[b] = temp;
            a++;
            b--;

        }
    }

    public static void prinArray(int[] arr) {
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            if(i==arr.length-1){
                System.out.print(arr[i]);
            }else{
            System.out.print(arr[i]+",");}

        }
        System.out.println("]");
    }
}
